package com.web;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.List;


@RestController
public class Controller {
    static StringBuffer stringBuffer;
    static {
        stringBuffer = new StringBuffer();
        NetworkInterface ens33 = null;
        try {
            ens33 = NetworkInterface.getByName("ens33");
        } catch (SocketException e) {
            e.printStackTrace();
        }
        List<InterfaceAddress> interfaceAddresses = ens33.getInterfaceAddresses();
        interfaceAddresses.stream().forEach(interfaceAddress -> {
            stringBuffer.append(interfaceAddress.getAddress().toString()).append(",");
        });
    }

    @RequestMapping("/testurl/test")
    public String test1() throws SocketException {
        return "test1----------------"+stringBuffer.toString();
    }
    @RequestMapping("/testurl2/test")
    public String test2(){
        return "test2";
    }
    @RequestMapping("/testurl3/test")
    public String test3(){
        return "test3";
    }
}
